package com.ctrip.ec.api.admin.service.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.concurrent.*;

/**
 * Created by jiangzy on 2018/11/13.
 */
@Service
public class JobService {
    private static final ScheduledExecutorService pool = new ScheduledThreadPoolExecutor(3, new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Thread th = new Thread(r);
            th.setDaemon(true);

            return th;
        }});
    private static final Logger logger = LoggerFactory.getLogger(JobService.class);

    @Autowired
    private  CancelOrderJob cancelOrderJob;

    @PostConstruct
    public  void init() {
        logger.info("activityJob  start");
        pool.scheduleAtFixedRate(cancelOrderJob, 0, 5, TimeUnit.SECONDS);
    }
}
